package economy;

import org.bukkit.entity.Player;

public class Money {
	private Player player;
	private int amount;

	public Money(Player player, int amount) {
		this.player = player;
		this.amount = amount;
	}

	public int amount() {
		return amount;
	}

	private String balance() {
		return Integer.toString(amount);
	}

	public void checkBalance() {
		player.sendMessage("You have $" + balance());
	}

	public void death() {
		amount = amount / 2;
		checkBalance();
	}

	public void deposit(int payment) {
		amount = amount + payment;
		checkBalance();
	}

	public boolean withdraw(int payment) {
		if (amount - payment >= 0) {
			amount = amount - payment;
			checkBalance();
			return true;
		} else {
			player.sendMessage("You do not have enough money!");
			return false;
		}
	}
}
